package org.example.erp.controller;

import org.example.erp.domain.Inventory;
import org.example.erp.service.impl.InventoryServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class InventoryController {

    @Autowired
    private InventoryServiceImpl inventoryService;


    @GetMapping("/warehouSeonhand/find")
    public DataResult find(@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage,
                           @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                           @RequestParam (required = false)String materialProductCode,
                           @RequestParam (required = false)   String materialProductName,
                           @RequestParam (required = false)  String inboundBatchNumber,
                           @RequestParam (required = false) String warehouseName,
                           @RequestParam (required = false) String supplierCode,
                           @RequestParam (required = false) String supplierName,
                           @RequestParam (required = false)String validityPeriodOfInventory,
                           @RequestParam (required = false) Integer materialId
    ){
        return DataResult.success(inventoryService.find(currentPage,pageSize,materialProductCode,materialProductName,inboundBatchNumber,warehouseName,supplierCode,supplierName,validityPeriodOfInventory,materialId)) ;
    }



    @PostMapping("/warehouSeonhand/insert")
    public DataResult insert(@RequestBody Inventory inventory){
        return DataResult.success(inventoryService.save(inventory));
    }
}






